home *** CD-ROM | disk | FTP | other *** search
/ JavaScript Source Code 2002 / JavaScript Source Code 2002.iso / page-details / resizableViewer.js < prev    next >
Text File  |  2001-03-13  |  2KB  |  52 lines

  1. arImageSrc = new Array ("../img/resizable-viewer/loading.gif","../img/resizable-viewer/loaded.gif");
  2. arImageList = new Array ();
  3. for (counter in arImageSrc) {
  4. arImageList[counter] = new Image();
  5. arImageList[counter].src = arImageSrc[counter];
  6. }
  7. var height = screen.height;
  8. var width = screen.width;
  9. var leftpos = width / 2 - 50;
  10. var toppos = height / 2 - 50; 
  11. function encode(str){ // Netscape fix thanks to Cyanide_7
  12. return escape(str.replace(/ /g,'+'));
  13. }
  14. function view(what) {
  15. var url = 'resizable-viewer-show.html?pic='+encode(what);
  16. window.open(url,'WIN','scrollbars=no,status=no,toolbar=no,resizable=1,location=no,menu=no,width=100,height=100,left=' + leftpos + ',top=' + toppos);
  17. }
  18. function getParams() {
  19. var idx = document.URL.indexOf('?');
  20. var params = new Array();
  21. if (idx != -1) {
  22. var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
  23. for (var i=0; i<pairs.length; i++) {
  24. nameVal = pairs[i].split('=');
  25. params[nameVal[0]] = nameVal[1];
  26.    }
  27. }
  28. return params;
  29. }
  30. params = getParams();
  31. function resize() {
  32. if (eval(pic).height) {
  33. var name = navigator.appName
  34. if (name == "Microsoft Internet Explorer") {
  35. myHeight = eval(pic).height + 40;
  36. myWidth = eval(pic).width + 12;
  37. }
  38. else {
  39. myHeight = eval(pic).height + 9;
  40. myWidth = eval(pic).width;
  41. }
  42. clearTimeout();
  43. var height = screen.height;
  44. var width = screen.width;
  45. var leftpos = width / 2 - myWidth / 2;
  46. var toppos = height / 2 - myHeight / 2; 
  47. self.moveTo(leftpos, toppos);
  48. self.resizeTo(myWidth, myHeight);
  49. document.il.src = '../img/resizable-viewer/loaded.gif';
  50. }
  51. else setTimeOut(resize(), 100);
  52. }